#include<iostream>
#include<map>
using namespace std;

class FoodRatings{
    //食物名字  --->  (评分，烹饪方式)
    map<string, pair<int, string>> fs;
    //食物名字  --->  (评分，烹饪方式)
    map<string, set<pair<int, string>>> cs;

public:
    FoodRatings(vector<string>& foods,vector<string>& cuisines,vector<int>& ratings){
        for(int i=0 ; i<food.size() ; ++i){
            auto &f = foods[i], c = cuisines[i];
            int r = ratings[i];
            fs[f]={r,c};
            //保证最小对应的是最高的评分
            cs[c].emplace(-r,f);
        }
    }

    void changeRating(string food,int newRating){
        auto &[r,c]=fs[food];
        auto &s = cs[c];
        //把旧的删除
        s.erase({-r,food});
        //把新的加到set
        s.emplace(-newRating, food);
        //修改评分
        r = newRating;
    }

    string highestRated(string cuisine){
        cs[cuisine].begin()->second;
    }


};